<?php

namespace App\Containers\AppSection\Authorization\Traits;

use App\Containers\AppSection\Profile\Tasks\FindProfileByIdTask;
use App\Containers\AppSection\User\Tasks\FindUserByIdTask;
use function app;

trait RoleTrait
{
    public function isInnerUser(): bool
    {
        $user = app(FindUserByIdTask::class)->run($this->id);
        return $user->hasRoleType('inner');
    }

    public function isOuterUser(): bool
    {
        $user = app(FindUserByIdTask::class)->run($this->id);
        return $user->hasRoleType('outer');
    }

    public function isInnerProfile(): bool
    {
        $profile = app(FindProfileByIdTask::class)->run($this->id);
        return $profile->user->hasRoleType('inner');
    }

    public function isOuterProfile(): bool
    {
        $profile = app(FindProfileByIdTask::class)->run($this->id);
        return $profile->user->hasRoleType('outer');
    }
}
